package o;

import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
import android.graphics.LinearGradient;
import android.graphics.RadialGradient;
import android.graphics.Shader;
import android.graphics.Shader.TileMode;
import android.graphics.SweepGradient;
import android.util.AttributeSet;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import java.io.IOException;
import java.util.List;
import o.ff.c;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

@RestrictTo({d.ॱ})
final class fq {

    static final class b {
        final int[] ˎ;
        final float[] ˏ;

        b(@NonNull List<Integer> list, @NonNull List<Float> list2) {
            int size = list.size();
            this.ˎ = new int[size];
            this.ˏ = new float[size];
            for (int i = 0; i < size; i++) {
                this.ˎ[i] = ((Integer) list.get(i)).intValue();
                this.ˏ[i] = ((Float) list2.get(i)).floatValue();
            }
        }

        b(@ColorInt int i, @ColorInt int i2) {
            this.ˎ = new int[]{i, i2};
            this.ˏ = new float[]{0.0f, 1.0f};
        }

        b(@ColorInt int i, @ColorInt int i2, @ColorInt int i3) {
            this.ˎ = new int[]{i, i2, i3};
            this.ˏ = new float[]{0.0f, 0.5f, 1.0f};
        }
    }

    static Shader ˋ(@NonNull Resources resources, @NonNull XmlPullParser xmlPullParser, @NonNull AttributeSet attributeSet, @Nullable Theme theme) throws IOException, XmlPullParserException {
        String name = xmlPullParser.getName();
        if (name.equals("gradient")) {
            TypedArray ˎ = fx.ˎ(resources, theme, attributeSet, c.ʿ);
            float ॱ = fx.ॱ(ˎ, xmlPullParser, "startX", c.ˍ, 0.0f);
            float ॱ2 = fx.ॱ(ˎ, xmlPullParser, "startY", c.ˋᐝ, 0.0f);
            float ॱ3 = fx.ॱ(ˎ, xmlPullParser, "endX", c.ˋˋ, 0.0f);
            float ॱ4 = fx.ॱ(ˎ, xmlPullParser, "endY", c.ˎˎ, 0.0f);
            float ॱ5 = fx.ॱ(ˎ, xmlPullParser, "centerX", c.ˊᐝ, 0.0f);
            float ॱ6 = fx.ॱ(ˎ, xmlPullParser, "centerY", c.ˊˋ, 0.0f);
            int ˊ = fx.ˊ(ˎ, xmlPullParser, "type", c.ˉ, 0);
            int ˎ2 = fx.ˎ(ˎ, xmlPullParser, "startColor", c.ʾ, 0);
            boolean ˊ2 = fx.ˊ(xmlPullParser, "centerColor");
            int ˎ3 = fx.ˎ(ˎ, xmlPullParser, "centerColor", c.ˌ, 0);
            int ˎ4 = fx.ˎ(ˎ, xmlPullParser, "endColor", c.ˈ, 0);
            int ˊ3 = fx.ˊ(ˎ, xmlPullParser, "tileMode", c.ˋˊ, 0);
            float ॱ7 = fx.ॱ(ˎ, xmlPullParser, "gradientRadius", c.ˊˊ, 0.0f);
            ˎ.recycle();
            b ॱ8 = ॱ(ॱ(resources, xmlPullParser, attributeSet, theme), ˎ2, ˎ4, ˊ2, ˎ3);
            switch (ˊ) {
                case 1:
                    if (ॱ7 > 0.0f) {
                        return new RadialGradient(ॱ5, ॱ6, ॱ7, ॱ8.ˎ, ॱ8.ˏ, ˋ(ˊ3));
                    }
                    throw new XmlPullParserException("<gradient> tag requires 'gradientRadius' attribute with radial type");
                case 2:
                    return new SweepGradient(ॱ5, ॱ6, ॱ8.ˎ, ॱ8.ˏ);
                default:
                    return new LinearGradient(ॱ, ॱ2, ॱ3, ॱ4, ॱ8.ˎ, ॱ8.ˏ, ˋ(ˊ3));
            }
        }
        throw new XmlPullParserException(xmlPullParser.getPositionDescription() + ": invalid gradient color tag " + name);
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private static o.fq.b ॱ(@androidx.annotation.NonNull android.content.res.Resources r7, @androidx.annotation.NonNull org.xmlpull.v1.XmlPullParser r8, @androidx.annotation.NonNull android.util.AttributeSet r9, @androidx.annotation.Nullable android.content.res.Resources.Theme r10) throws org.xmlpull.v1.XmlPullParserException, java.io.IOException {
        /*
        r3 = 20;
        r0 = r8.getDepth();
        r0 = r0 + 1;
        r1 = new java.util.ArrayList;
        r1.<init>(r3);
        r2 = new java.util.ArrayList;
        r2.<init>(r3);
    L_0x0012:
        r3 = r8.next();
        r4 = 1;
        if (r3 == r4) goto L_0x0086;
    L_0x0019:
        r4 = r8.getDepth();
        if (r4 >= r0) goto L_0x0022;
    L_0x001f:
        r5 = 3;
        if (r3 == r5) goto L_0x0086;
    L_0x0022:
        r5 = 2;
        if (r3 != r5) goto L_0x0012;
    L_0x0025:
        if (r4 > r0) goto L_0x0012;
    L_0x0027:
        r3 = r8.getName();
        r4 = "item";
        r3 = r3.equals(r4);
        if (r3 == 0) goto L_0x0012;
    L_0x0033:
        r3 = o.ff.c.ˑ;
        r3 = o.fx.ˎ(r7, r10, r9, r3);
        r4 = o.ff.c.ˏˏ;
        r4 = r3.hasValue(r4);
        r5 = o.ff.c.ͺॱ;
        r5 = r3.hasValue(r5);
        if (r4 == 0) goto L_0x0049;
    L_0x0047:
        if (r5 != 0) goto L_0x0066;
    L_0x0049:
        r0 = new org.xmlpull.v1.XmlPullParserException;
        r1 = new java.lang.StringBuilder;
        r1.<init>();
        r2 = r8.getPositionDescription();
        r1 = r1.append(r2);
        r2 = ": <item> tag requires a 'color' attribute and a 'offset' attribute!";
        r1 = r1.append(r2);
        r1 = r1.toString();
        r0.<init>(r1);
        throw r0;
    L_0x0066:
        r4 = o.ff.c.ˏˏ;
        r5 = 0;
        r4 = r3.getColor(r4, r5);
        r5 = o.ff.c.ͺॱ;
        r6 = 0;
        r5 = r3.getFloat(r5, r6);
        r3.recycle();
        r3 = java.lang.Integer.valueOf(r4);
        r2.add(r3);
        r3 = java.lang.Float.valueOf(r5);
        r1.add(r3);
        goto L_0x0012;
    L_0x0086:
        r0 = r2.size();
        if (r0 <= 0) goto L_0x0092;
    L_0x008c:
        r0 = new o.fq$b;
        r0.<init>(r2, r1);
    L_0x0091:
        return r0;
    L_0x0092:
        r0 = 0;
        goto L_0x0091;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.fq.ॱ(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet, android.content.res.Resources$Theme):o.fq$b");
    }

    private static b ॱ(@Nullable b bVar, @ColorInt int i, @ColorInt int i2, boolean z, @ColorInt int i3) {
        if (bVar != null) {
            return bVar;
        }
        if (z) {
            return new b(i, i3, i2);
        }
        return new b(i, i2);
    }

    private static TileMode ˋ(int i) {
        switch (i) {
            case 1:
                return TileMode.REPEAT;
            case 2:
                return TileMode.MIRROR;
            default:
                return TileMode.CLAMP;
        }
    }
}
